﻿
var sysmain = $.extend({}, sysmain); /* 定义全局对象，类似于命名空间或包的作用 */

/*更改主题*/
function changeTheme(themename) {
    var $easyuitheme = $("#easyuiTheme");
    var url = $easyuitheme.attr('href');
    var href = url.substring(0, url.indexOf('themes')) + 'themes/' + themename + '/easyui.css';
    $easyuitheme.attr('href', href);
    $.cookie('easyuiThemeName', themename, {
        expires: 7
    });
}
/*创建tab*/
function createTab(title, url, ico) {
    if ($('#Home_Index_Tabs').tabs('exists', title)) {
        $('#Home_Index_Tabs').tabs('select', title);
    }
    else {
        $('#Home_Index_Tabs').tabs('add', {
            title: title,
            content: '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.6%;"></iframe>',
            closable: true,
            iconCls: ico
        });
    }
}
function addaccordionitem(obj) {
    if (obj._parentId == 0) {
        var _accordion = $('#easyui-accordion').accordion('add', {
            title: obj.ModuleName,
            iconCls: obj.iconCls,
            selected: true
        });
        var panels = $("#easyui-accordion").accordion('panels')
        panels[panels.length - 1].panel('options').id = 'easyui-accordion-item-' + obj.ModuleID;
        panels[panels.length - 1].append('<ul></ul>');
        alert(panels[panels.length - 1].panel('options').id);
    }
    else {
        var panels = $("#easyui-accordion").accordion('panels');
        if (panels.length > 0) {
            for (var i = 0; i < panels.length; i++) {
                if (panels[i].panel('options').id == ('easyui-accordion-item-' + obj._parentId)) {
                    $('#easyui-accordion').accordion('select', panels[i].panel('options').title);
                    panels[i].find('ul').append('<li class="menuitem ' + obj.iconCls + '"><a href="javascript:createTab("' + obj.ModuleName + '","' + obj.Href + '","' + obj.iconCls + '")">' + obj.ModuleName + '</a></li>');
                    break;
                }
            }
        }
    }
}
/**
* @author 孙宇
* 
* @requires jQuery,EasyUI
* 
* @param options
*/
sysmain.dialog = function (options) {
    var opts = $.extend({
        modal: true,
        onClose: function () {
            $(this).dialog('destroy');
        }
    }, options);
    return $('<div/>').dialog(opts);
};
/**
* @author 孙宇
* 
* @requires jQuery,EasyUI
* 
* @param title
*            标题
* 
* @param msg
*            提示信息
* 
* @param fun
*            回调方法
*/
sysmain.messagerConfirm = function (title, msg, fn) {
    return $.messager.confirm(title, msg, fn);
};

/**
* @author 孙宇
* 
* @requires jQuery,EasyUI
*/
sysmain.messagerShow = function (options) {
    return $.messager.show(options);
};

/**
* @author 孙宇
* 
* @requires jQuery,EasyUI
*/
sysmain.messagerAlert = function (title, msg, icon, fn) {
    return $.messager.alert(title, msg, icon, fn);
};